import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProQualityAudrecordVO, ProQualityAudrecordForm, ProQualityAudrecordQuery, ProQualityExternalaudVO, ProQualityExternalaudForm, ProQualityExternalaudQuery } from '@/api/project/quality/types';

/**
 * 查询项目审查记录列表
 * @param query
 * @returns {*}
 */

export const listProQualityAudrecord = (query?: ProQualityAudrecordQuery): AxiosPromise<ProQualityAudrecordVO[]> => {
  return request({
    url: '/pro/quality/auditRecord/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询项目审查记录详细
 * @param id
 */
export const getProQualityAudrecord = (id: string | number): AxiosPromise<ProQualityAudrecordVO> => {
  return request({
    url: '/pro/quality/auditRecord/' + id,
    method: 'get'
  });
};

/**
 * 新增项目审查记录
 * @param data
 */
export const addProQualityAudrecord = (data: ProQualityAudrecordForm) => {
  return request({
    url: '/pro/quality/auditRecord',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目审查记录
 * @param data
 */
export const updateProQualityAudrecord = (data: ProQualityAudrecordForm) => {
  return request({
    url: '/pro/quality/auditRecord',
    method: 'put',
    data: data
  });
};

/**
 * 删除项目审查记录
 * @param id
 */
export const delProQualityAudrecord = (id: string | number | Array<string | number>) => {
  return request({
    url: '/pro/quality/auditRecord/' + id,
    method: 'delete'
  });
};

// 对外输出资料清单

/**
 * 查询项目成果对外输出审批列表
 * @param query
 * @returns {*}
 */

export const listProQualityExternalaud = (query?: ProQualityExternalaudQuery): AxiosPromise<ProQualityExternalaudVO[]> => {
  return request({
    url: '/pro/quality/externalAudit/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询项目成果对外输出审批详细
 * @param id
 */
export const getProQualityExternalaud = (id: string | number): AxiosPromise<ProQualityExternalaudVO> => {
  return request({
    url: '/pro/quality/externalAudit/' + id,
    method: 'get'
  });
};

/**
 * 新增项目成果对外输出审批
 * @param data
 */
export const addProQualityExternalaud = (data: ProQualityExternalaudForm) => {
  return request({
    url: '/pro/quality/externalAudit',
    method: 'post',
    data: data
  });
};

/**
 * 修改项目成果对外输出审批
 * @param data
 */
export const updateProQualityExternalaud = (data: ProQualityExternalaudForm) => {
  return request({
    url: '/pro/quality/externalAudit',
    method: 'put',
    data: data
  });
};

/**
 * 删除项目成果对外输出审批
 * @param id
 */
export const delProQualityExternalaud = (id: string | number | Array<string | number>) => {
  return request({
    url: '/pro/quality/externalAudit/' + id,
    method: 'delete'
  });
};

/**
 * 查询项目的公司审核记录
 * @param proId 项目ID
 */
export const fetchAuditRecordByProId = (proId: string | number): Promise<any> => {
  return request({
    url: `/pro/quality/externalAudit/query/${proId}`,
    method: 'get'
  });
};
